<nz-layout>
  <nz-header>
    <div class="logo">后台任务调度</div>
    <ul nz-menu nzTheme="dark" nzMode="horizontal" style="float: right">
      <li nz-menu-item (click)="taskpage()">后台任务</li>
      <li nz-menu-item [nzSelected]="true">SSh服务器</li>
      <li nz-menu-item (click)="loginout()">安全退出</li>
    </ul>
  </nz-header>
  <nz-content>
    <div class="inner-content">
      <div nz-row>
        <div nz-col nzSpan="8">SSh服务器列表</div>
        <div nz-col nzSpan="16" style="text-align: right">
          <nz-space>

            <button nz-button nzType="primary" (click)="newSshServer()" *nzSpaceItem>
              <i nz-icon nzType="plus"></i>新建
            </button>


            <button nz-button nzType="primary" style="border-color: #2db7f5; background-color: #2db7f5"
              (click)="searchData()" *nzSpaceItem>
              <i nz-icon nzType="redo" nzTheme="outline"></i>刷新数据
            </button>

          </nz-space>
        </div>
      </div>
      <div nz-row style="margin-top: 20px">
        <div nz-col nzSpan="24">
          <nz-table #Task nzBordered nzShowPagination nzShowSizeChanger [nzData]="listOfCurrentPageData"
            [nzFrontPagination]="false" [nzTotal]="total" [(nzPageIndex)]="pageindex" [(nzPageSize)]="pagesize"
            [nzLoading]="tableloading" (nzPageIndexChange)="searchData()">
            <thead>
              <tr>
                <th>服务器</th>
                <th>端口</th>
                <th>超时时间</th>
                <th>终端类型</th>
                <th>字符集</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <tr *ngFor="let item of Task.data">
                <td>{{ item.ServerName }}</td>
                <td>{{ item.Port }}</td>
                <td>{{ item.IdleTimeoutMs }}</td>
                <td>{{ item.TermType }}</td>
                <td>{{ item.Charset }}</td>
                <td>
                  <button nz-button nzType="primary" (click)="update(item.ID)"
                    style="border-color: #ed4014; background-color: #ed4014">
                    <i nz-icon nzType="tool" nzTheme="outline"></i>修改
                  </button>
                  <nz-divider nzType="vertical"></nz-divider>
                  <button nz-button nzType="default" (click)="deleteOne(item.ID)">
                    <i nz-icon nzType="close" nzTheme="outline"></i>删除
                  </button>
                  <nz-divider nzType="vertical"></nz-divider>
                  <button nz-button nzType="primary" (click)="execshell(item)"
                    style="border-color: #19be6b; background-color: #19be6b">
                    <i nz-icon nzType="caret-right" nzTheme="outline"></i>执行脚本
                  </button>
                </td>
              </tr>
            </tbody>
          </nz-table>
        </div>
      </div>
    </div>
  </nz-content>
</nz-layout>
<nz-drawer [nzBodyStyle]="{
    height: 'calc(100% - 55px)',
    overflow: 'auto',
    'padding-bottom': '53px'
  }" [nzMaskClosable]="false" [nzWidth]="720" [nzVisible]="visible" [nzMaskClosable]="true" nzTitle="任务信息"
  (nzOnClose)="close()">
  <ng-container *nzDrawerContent>
    <form nz-form>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>服务器地址</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.ServerName" name="ServerName" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>端口</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.Port" name="Port" type="number" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>用户名</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.LoginName" name="LoginName" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>密码</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.PassWord" name="PassWord" type="password" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>超时时间</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.IdleTimeoutMs" name="IdleTimeoutMs" type="number" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>终端类型</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <nz-select [(ngModel)]="item.TermType" name="method">
            <nz-option nzValue="dumb" nzLabel="dumb"></nz-option>
            <nz-option nzValue="xterm" nzLabel="xterm"></nz-option>
            <nz-option nzValue="vt100" nzLabel="vt100"></nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>WidthInChars</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.WidthInChars" name="WidthInChars" type="number" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>HeightInChars</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.HeightInChars" name="HeightInChars" type="number" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>PixWidth</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.PixWidth" name="PixWidth" type="number" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>PixHeight</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.PixHeight" name="PixHeight" type="number" />
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>PollTimeoutMs</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.PollTimeoutMs" name="PollTimeoutMs" type="number" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>Charset</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <input nz-input [(ngModel)]="item.Charset" name="Charset" />
        </nz-form-control>
      </nz-form-item>
    </form>
    <nz-divider></nz-divider>
    <button nz-button nzType="primary" (click)="AddOrEditSsh()">提交</button>
  </ng-container>

</nz-drawer>
<nz-modal [(nzVisible)]="isModelVisible" nzTitle="执行shell" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"
  [nzOkLoading]="okloading">
  <ng-container *nzModalContent>
    <form nz-form>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24">shell</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <textarea rows="5" nz-input [(ngModel)]="shellcontent" name="shellcontent"></textarea>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="6" [nzXs]="24">结果</nz-form-label>
        <nz-form-control [nzSm]="14" [nzXs]="24">
          <!-- <textarea
            nz-input
            [(ngModel)]="shellresult"
            name="shellresult"
          ></textarea> -->
          <p>
            {{ shellresult }}
          </p>
        </nz-form-control>
      </nz-form-item>
    </form>
  </ng-container>

</nz-modal>